package mercurius.fitness.client.rb.diet.forms;

import com.google.gwt.user.client.rpc.AsyncCallback;

import mercurius.fitness.client.locale.Locale;
import mercurius.fitness.client.rb.diet.Diet;
import mercurius.fitness.client.rb.diet.DietRB;
import net.pleso.framework.client.bl.forms.IAddForm;
import net.pleso.framework.client.bl.forms.items.IFormItemsGroup;
import net.pleso.framework.client.dal.IDataRow;

public class AddDietForm extends DietForm implements IAddForm {

	private String type = "";
	
	public AddDietForm(String type) {
		this.type = type;
	}
	
	public IDataRow createEmptyRow() {
		return new Diet();
	}

	public void addRow(IDataRow row, AsyncCallback callback) {
		DietRB.getDataSet().add((Diet) row, callback,type);
	}

	public String getCaption() {
		return Locale.constants().add_diet_caption();
	}

	public IFormItemsGroup[] getGroups() {
		if(type.equals(Diet.TYPE_LOG)) {
			return groups_log;
		} else if(type.equals(Diet.TYPE_MASTER_REPOSITORY)) {
			
		} else if(type.equals(Diet.TYPE_PRIVATE_REPOSITORY)) {
			return groups_nutrition;
		}
		return null;  // It should never reach here.
	}
}
